package com.dragon.im.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;

public class DataConverter implements Converter<String, Date> {

	SimpleDateFormat formart = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	public DataConverter() { }
	public DataConverter(String formart) { 
		this.formart = new SimpleDateFormat(formart);
	}
	
	@Override
	public Date convert(String txt) {
		try {
			return formart.parse(txt.trim());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		//�޷�ת��ʱ����null
		return null;
	}

}
